package com.cspg.ssss.service;

import com.cspg.ssss.repository.SelectWenTiMapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
public class SelectWenTiService {
    @Autowired
    SelectWenTiMapper selectWenTiMapper;

    public PageInfo<Map> selectwemti(Map<String, Object> map) {
        Page pg = PageHelper.startPage(Integer.parseInt(map.get("pageNum").toString()), Integer.parseInt(map.get("pageSize").toString()));
        List<Map> list = selectWenTiMapper.selectwemti(map);
        PageInfo<Map> pgInfo = new PageInfo<>(list);
        pgInfo.setPageNum(pg.getPageNum());
        pgInfo.setPageSize(pg.getPageSize());
        pgInfo.setTotal(pg.getTotal());
        pgInfo.setPages(pg.getPages());
        return pgInfo;
    }

    public List<Map> selectwemtidw(Map<String, Object> map) {
        return selectWenTiMapper.selectwemtidw(map);
    }

    public List<Map> selectdeptrectify(String id) {
        return selectWenTiMapper.selectdeptrectify(id);
    }

    public List<Map> selectgz(String id) {
        return selectWenTiMapper.selectgz(id);
    }

    @Transactional(rollbackFor = Exception.class)
    public int bacthinsert(List<Map> list) {
        int c = 0;
        try {
            c = selectWenTiMapper.bacthinsert(list);
        } catch (Exception e) {
            e.printStackTrace();
            return c;
        }
        return c;
    }

    public List<Map> selectrectify(String id) {
        return selectWenTiMapper.selectrectify(id);
    }

    public int insertrectify(Map map) {
        return selectWenTiMapper.insertrectify(map);
    }

    public int updaterectify(Map map) {
        return selectWenTiMapper.updaterectify(map);
    }
}
